public class D9 implements Runnable {
    // sync关键字是一次只能被一个线程访问
    public synchronized void showDetail() {
        System.out.println("Yes I can show only in one thread one time");
    }

    public static void main(String[] args) {
        D9 d = new D9();
        d.run();
        d.stop();
        d.showDetail();    
    }
    
    private volatile boolean is_active;
    
    public void run() {
        is_active = true;
        while(is_active) {
            System.out.println("HHHHHH, I am running");
        }

    }

    public void stop() {
        is_active = false;
    }
}
